import sqlite3
import streamlit as st

if __name__ == '__main__':

    with sqlite3.connect('test.db') as conn:
        cursor = conn.cursor()

        st.header('登录页面')
        username = st.text_input('用户名', placeholder='请输入用户名', key='username')
        password = st.text_input('密码', placeholder='请输入密码', key='password', type='password')
        if st.button('登录'):
            cursor.execute('SELECT * FROM users WHERE name = ? AND password = ?', (username, password))
            result = cursor.fetchone()
            if result:
                st.success('登录成功')
            else:
                st.error('用户名或密码错误')